package cn.kgc.tangcco.array;

import org.junit.Test;

/**
 * @author 李昊哲
 * @Description
 * @date 2020/8/14 上午10:07
 */
public class Demo01 {
    @Test
    public void test01() {
        int a = 10;
        int b = 20;
        int c = 30;
    }

    @Test
    public void test02() {
        int a = 10, b = 20, c = 30;
    }
    @Test
    public void test03() {
        // 相同数据类型的元素组成的集合我能称之为数组
        // 数组中能够存储元素的数量最大值我们称之为该数组的长度
        // 数组声明后该数组的长度不可修改
        // 数组声明后没有赋值的index位置上赋值为该数组数据类型的初始值 如果是引用类型则为null
        int[] arr0 = new int[5];
        // 数组的赋值
        arr0[0] = 5;
        arr0[1] = 15;
        arr0[2] = 25;
        arr0[3] = 35;
        arr0[4] = 45;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }
    @Test
    public void test04() {
        int[] arr0 = new int[5];
        // 数组的赋值
        arr0[0] = 5;
        arr0[1] = 15;
        arr0[2] = 25;
        arr0[3] = 35;
        arr0[4] = 45;
        // java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
        // 数组下标越界
        arr0[5] = 55;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[5]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }

    @Test
    public void test05() {
        int[] arr0 = new int[5];
        // 数组的赋值
        arr0[0] = 5;
        arr0[1] = 15;
        arr0[2] = 25;
        arr0[3] = 35;
        arr0[4] = 45;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        // java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
        // 数组下标越界
        System.out.println(arr0[5]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }
    @Test
    public void test06() {
        int[] arr0 = new int[5];
        // 数组的赋值
        arr0[0] = 5;
        arr0[1] = 15;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }
    @Test
    public void test07() {
        char[] arr0 = new char[5];
        // 数组的赋值
        arr0[0] = 'a';
        arr0[4] = 'e';
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }
    @Test
    public void test08() {
        boolean[] arr0 = new boolean[5];
        // 数组的赋值
        arr0[0] = true;
        arr0[4] = true;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }

    @Test
    public void test09() {
        double[] arr0 = new double[5];
        // 数组的赋值
        arr0[0] = 3.14;
        arr0[4] = 0.926;
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }
    @Test
    public void test10() {
        String[] arr0 = new String[5];
        // 数组的赋值
        arr0[0] = "我";
        arr0[4] = "你";
        // 读取数组中元素的值
        System.out.println(arr0[0]);
        System.out.println(arr0[1]);
        System.out.println(arr0[2]);
        System.out.println(arr0[3]);
        System.out.println(arr0[4]);
    }

}
